package com.yizhu.zczy.advertising.controller;

import java.util.Arrays;
import java.util.Map;


import com.yizhu.zczy.advertising.service.AdService;
import com.yizhu.zczy.common.utils.PageUtils;
import com.yizhu.zczy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yizhu.zczy.advertising.entity.AdEntity;




/**
 * 广告表
 *
 * @author guoyz
 * @email guoyz@mail.com
 * @date 2021-06-24 17:23:20
 */
@RestController
@RequestMapping("advertising/ad")
public class AdController {
    @Autowired
    private AdService adService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("advertising:ad:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = adService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{adId}")
    //@RequiresPermissions("advertising:ad:info")
    public R info(@PathVariable("adId") Integer adId){
		AdEntity ad = adService.getById(adId);

        return R.ok().put("ad", ad);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("advertising:ad:save")
    public R save(@RequestBody AdEntity ad){
		adService.save(ad);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("advertising:ad:update")
    public R update(@RequestBody AdEntity ad){
		adService.updateById(ad);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("advertising:ad:delete")
    public R delete(@RequestBody Integer[] adIds){
		adService.removeByIds(Arrays.asList(adIds));

        return R.ok();
    }

}
